/*
 *  $Id: Savior.cs 1051 2010-05-18 22:10:41Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

namespace Ragima.Cards001.Light.Spells {
    public class Savior: SpellCard<ChainData> {
        public Savior(): base("001_l_s_savior") {
            Level = CompleteLevel.ReadyForTest;
            Element = ElementType.Light;
            Value = 100;
            Target = new ChainTarget(TestCost,
                new CreatureTarget(GetNewPhrase("target1"), true, false, CreatureTarget.IsHoly),
                new CreatureTarget(GetNewPhrase("target2"), false, true, CreatureTarget.IsNotHoly));
            AddManaCost(ElementType.Light, 4);
        }

        private static readonly Languages.CardPhrase<Savior> GreatCost = new Languages.CardPhrase<Savior>("great_cost");

        public static bool TestCost(TargetArgs<ChainData> args) {
            TargetArgs<Creature> victim, target;
            if (!args.Target.GetArgs(out victim, out target)) return false;
            bool test = target.Target.Card.GetSumMana() < victim.Target.Card.GetSumMana()*2;
            if (!test) args.Player.Game.ErrorNotice(GreatCost.Phrase.GetText());
            return test;
        }

        protected override void DoAction(TargetArgs<ChainData> args) {
            TargetArgs<Creature> victim, target;
            if (!args.Target.GetArgs(out victim, out target)) return;
            victim.Target.InstantDeath();
            args.Player.Game.DoDeath();
            target.Target.MoveToPlayer(args.Player);
        }
    }
}
